import java.io.BufferedReader;

public class NeighbouringNumbers {
	public static int getNeighbouringNumbersIndex(int[] array) {
		int smallestDistanceIndex;
		int smallestNumbersDistance;
		
		if (array.length < 1) {
			return -1;
		} else {
			smallestDistanceIndex = 0;
			smallestNumbersDistance = Math.abs(array[0] - array[1]);
			for (int index = 1; index < array.length - 1; ++index) {
				if (Math.abs(array[index] - array[index + 1]) < smallestNumbersDistance) {
					smallestDistanceIndex = index;
					smallestNumbersDistance = Math.abs(array[index] - array[index + 1]);
				}
			}
			
			return smallestDistanceIndex;
		}
	}
	
	public static void main(String[] args) {
		BufferedReader consoleReader = new BufferedReader(new java.io.InputStreamReader(System.in));
		int dimension = -1;
		int[] array;
		
		System.out.print("Enter dimension of array: ");
		try {
			dimension = new Integer(consoleReader.readLine()).intValue();
			
			if (dimension <= 0) {
				System.out.println("Dimension of array must be more than 0.");
				return;
			} else {
				System.out.println("Enter elements of array: ");
				array = new int[dimension];
				
				for (int index = 0; index < dimension; ++index) {
					System.out.print("[" + index + "]= ");
					array[index] = new Integer(consoleReader.readLine()).intValue();
				}
				
				System.out.println("Index of smallest distanse of numbers: " + NeighbouringNumbers.getNeighbouringNumbersIndex(array));
			}
		} catch (java.lang.NumberFormatException  ex) {
			System.out.println("Error! Wrong number.");
			return;
		} catch (java.io.IOException ex) {
			System.out.println("Caught IO error!");
			System.out.println(ex);
			return;
		}
	}
}